package com.xdcplus.web.controller;



import com.fasterxml.jackson.core.JsonProcessingException;
import com.xdcplus.mom.controller.AbstractController;
import com.xdcplus.exceptions.domain.ResponseVO;

import com.xdcplus.pager.vo.PageVO;
import com.xdcplus.web.common.pojo.dto.ToolProductionLineOpeDTO;
import com.xdcplus.web.common.pojo.dto.ToolProductionLineOpeFilterDTO;
import com.xdcplus.web.common.pojo.vo.ToolDmIvSummaryVO;
import com.xdcplus.web.common.pojo.vo.ToolProductionLineOpeVO;
import com.xdcplus.web.service.ToolProductionLineOpeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Validation;
import javax.validation.constraints.NotNull;


/**
 * (ToolProductionLineOpe)表服务控制层
 *
 * @author Man.Chen
 * @since 2024-12-03 16:40:35
 */
@Api(tags = "(ToolProductionLineOpe)") 
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("toolProductionLineOpe")
public class ToolProductionLineOpeController extends AbstractController {

    @Autowired
    private ToolProductionLineOpeService toolProductionLineOpeService;

    @ApiOperation("新增")
    @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO saveToolProductionLineOpe(@RequestBody ToolProductionLineOpeDTO toolProductionLineOpeDTO) {

        log.info("saveToolProductionLineOpe {}", toolProductionLineOpeDTO.toString());

        toolProductionLineOpeDTO.setCreatedUser(getAccount());
        toolProductionLineOpeService.saveToolProductionLineOpe(toolProductionLineOpeDTO);

        return ResponseVO.success();
    }

    @ApiOperation("修改")
    @PutMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO updateToolProductionLineOpe(@RequestBody ToolProductionLineOpeDTO toolProductionLineOpeDTO) {

        log.info("updateToolProductionLineOpe {}", toolProductionLineOpeDTO.toString());

        toolProductionLineOpeDTO.setUpdatedUser(getAccount());
        toolProductionLineOpeService.updateToolProductionLineOpe(toolProductionLineOpeDTO);

        return ResponseVO.success();
    }

    @ApiOperation("删除")
    @DeleteMapping(value = "/{toolProductionLineOpeId}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "toolProductionLineOpeId", dataTypeClass = Long.class, value = "ID", required = true),
    })
    public ResponseVO deleteToolProductionLineOpeLogical(@PathVariable("toolProductionLineOpeId")
                                         @NotNull(message = "ID不能为空") Long toolProductionLineOpeId) {

        log.info("deleteToolProductionLineOpeLogical {}", toolProductionLineOpeId);

        toolProductionLineOpeService.deleteToolProductionLineOpeLogical(toolProductionLineOpeId);

        return ResponseVO.success();
    }
    
    @ApiOperation("批量删除")
    @DeleteMapping(value = "/deleteByIds/{toolProductionLineOpeIds}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "toolProductionLineOpeId", dataTypeClass = Long.class, value = "ID", required = true),
    })
    public ResponseVO deleteToolProductionLineOpeLogical(@PathVariable("toolProductionLineOpeIds")
                                         @NotNull(message = "ID不能为空") String toolProductionLineOpeIds) {

        log.info("deleteToolProductionLineOpeByIds {}", toolProductionLineOpeIds);

        toolProductionLineOpeService.deleteToolProductionLineOpeByIds(toolProductionLineOpeIds);

        return ResponseVO.success();
    }

    @ApiOperation("查询")
    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<PageVO<ToolProductionLineOpeVO>> findToolProductionLineOpe(ToolProductionLineOpeFilterDTO toolProductionLineOpeFilterDTO) {

        log.info("findToolProductionLineOpe {}", toolProductionLineOpeFilterDTO);

        Validation.buildDefaultValidatorFactory().getValidator().validate(toolProductionLineOpeFilterDTO);

        return ResponseVO.success(toolProductionLineOpeService.queryToolProductionLineOpe(toolProductionLineOpeFilterDTO));
    }


    @ApiOperation("获取电性能报表")
    @GetMapping(value = "/queryElectricityPerformanceReport", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<ToolDmIvSummaryVO> queryElectricityPerformanceReport(@RequestParam("id")
                                         @NotNull(message = "ID不能为空") Long id) {

        log.info("queryElectricityPerformanceReport {}", id);


        return ResponseVO.success(toolProductionLineOpeService.queryElectricityPerformanceReport(id));
    }


}
